package com.hdu.dwh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hdu.dwh.pojos.DatabaseAll;
import com.hdu.dwh.pojos.SubjectDatabaseSource;
import com.hdu.dwh.mapper.SubjectDatabaseSourceMapper;
import com.hdu.dwh.service.ISubjectDatabaseSourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 主题数据库与源数据库关联表 服务实现类
 * </p>
 *
 * @author bobo
 * @since 2025-04-08
 */
@Service
public class SubjectDatabaseSourceServiceImpl extends ServiceImpl<SubjectDatabaseSourceMapper, SubjectDatabaseSource> implements ISubjectDatabaseSourceService {

    @Override
    public boolean deleteByDatabaseId(Long id) {
        if(id != null){
            LambdaQueryWrapper<SubjectDatabaseSource> queryWrapper = new LambdaQueryWrapper<SubjectDatabaseSource>()
                    .eq(SubjectDatabaseSource::getSubjectDatabaseId, id);
            if(count(queryWrapper)==0){
                return true;
            }
            return remove(queryWrapper);
        }
        return true;
    }
}
